package com.neusoft.hifly.information.comment.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import com.neusoft.hifly.commons.lang.LocalDateUtil;
import com.neusoft.hifly.core.utils.GlobalConstants;
import io.swagger.annotations.ApiModelProperty;

/**
 * Title: 文章资讯服务
 * <p>
 * Description: 文章评论对象
 * <p>
 * Copyright: 2019
 * <p>
 * Company: 东软汉枫
 *
 * @author lh_neu
 * @version 1.0.0
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName(value = GlobalConstants.DYNAMIC_TABLE_NAME_PREFIX + "_INFO_ART_COMMENT")
public class ArticleCommentObj implements Serializable {
	private static final long serialVersionUID = -158218514193119L;
	// 主键
	@TableId(value = "ID")
	@ApiModelProperty(value = "主键")
	private long id;
	// 逻辑ID
	@TableField(value = "LOGIC_ID")
	@ApiModelProperty(value = "逻辑ID")
	private long logicId;
	// 租户逻辑ID
	@TableField(value = "ORGAN_LOGIC_ID")
	@ApiModelProperty(value = "租户逻辑ID")
	private long organLogicId;
	// 评论父ID（盖楼）
	@TableField(value = "PID")
	@ApiModelProperty(value = "评论父ID（盖楼）")
	private long pid;
	// 文章逻辑ID
	@TableField(value = "ARTICLE_LOGIC_ID")
	@ApiModelProperty(value = "文章逻辑ID")
	private long articleLogicId;
	// 评论人
	@TableField(value = "USER_NAME")
	@ApiModelProperty(value = "评论人")
	private String userName;
	// 评论人ID
	@TableField(value = "USER_LOGIC_ID")
	@ApiModelProperty(value = "评论人ID")
	private long userLogicId;
	// 评论内容
	@TableField(value = "CONTENT")
	@ApiModelProperty(value = "评论内容")
	private String content;
	// 评论时间
	@TableField(value = "CONTENT_TIME")
	@ApiModelProperty(value = "评论时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	private LocalDateTime contentTime;
	// 是否匿名(默认0否、1是)
	@TableField(value = "IS_ANONYMOUS")
	@ApiModelProperty(value = "是否匿名(默认0否、1是)", example = "0")
	private String isAnonymous;
	// 署名
	@TableField(value = "SIGNATURE")
	@ApiModelProperty(value = "署名")
	private String signature;
	// 是否审核通过(默认0否、1是)
	@TableField(value = "IS_APPROVE")
	@ApiModelProperty(value = "是否审核通过(默认0否、1是)", example = "0")
	private String isApprove;
	// 审核人
	@TableField(value = "APPROVE_PERSON")
	@ApiModelProperty(value = "审核人")
	private String approvePerson;
	// 审核时间
	@TableField(value = "APPROVE_TIME")
	@ApiModelProperty(value = "审核时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	private LocalDateTime approveTime;
	// 扩展字段1
	@TableField(value = "EXT1")
	private String ext1;
	// 扩展字段2
	@TableField(value = "EXT2")
	private String ext2;
	// 扩展字段3
	@TableField(value = "EXT3")
	private String ext3;
	// 扩展字段4
	@TableField(value = "EXT4")
	private String ext4;
	// 扩展字段5
	@TableField(value = "EXT5")
	private String ext5;

	// ################### 临时数据 ####################

	// 格式化后的字符串日期
	@TableField(exist = false)
	private String contentTimeStr;
	// 租户
	@TableField(exist = false)
	private String organCode;

	/**
	 * 得到对象的哈希值
	 *
	 * @return int 对象的哈希值
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getLogicId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 *
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof ArticleCommentObj)) {
			return false;
		}
		final ArticleCommentObj castOther = (ArticleCommentObj) other;
		return new EqualsBuilder().append(this.getLogicId(), castOther.getLogicId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 *
	 * @return String 表示用户对象的字符串值
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("文章评论", this.getContent()).toString();
	}

	/**
	 * 将DATE类型的时间格式化为字符串类型
	 *
	 * @return 字符串时间
	 */
	public String getContentTimeStr() {
		if (this.contentTime != null) {
			this.contentTimeStr = LocalDateUtil.showTime(this.contentTime);
		}
		return this.contentTimeStr;
	}

	public long getId() {
		return id;
	}

	public void setId(final long id) {
		this.id = id;
	}

	public long getLogicId() {
		return logicId;
	}

	public void setLogicId(final long logicId) {
		this.logicId = logicId;
	}

	public long getOrganLogicId() {
		return organLogicId;
	}

	public void setOrganLogicId(final long organLogicId) {
		this.organLogicId = organLogicId;
	}

	public long getPid() {
		return pid;
	}

	public void setPid(final long pid) {
		this.pid = pid;
	}

	public long getArticleLogicId() {
		return articleLogicId;
	}

	public void setArticleLogicId(final long articleLogicId) {
		this.articleLogicId = articleLogicId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(final String userName) {
		this.userName = userName;
	}

	public long getUserLogicId() {
		return userLogicId;
	}

	public void setUserLogicId(final long userLogicId) {
		this.userLogicId = userLogicId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(final String content) {
		this.content = content;
	}

	public LocalDateTime getContentTime() {
		return contentTime;
	}

	public void setContentTime(final LocalDateTime contentTime) {
		this.contentTime = contentTime;
	}

	public String getIsAnonymous() {
		return isAnonymous;
	}

	public void setIsAnonymous(final String isAnonymous) {
		this.isAnonymous = isAnonymous;
	}

	public String getSignature() {
		return signature;
	}

	public void setSignature(final String signature) {
		this.signature = signature;
	}

	public String getIsApprove() {
		return isApprove;
	}

	public void setIsApprove(final String isApprove) {
		this.isApprove = isApprove;
	}

	public String getApprovePerson() {
		return approvePerson;
	}

	public void setApprovePerson(final String approvePerson) {
		this.approvePerson = approvePerson;
	}

	public LocalDateTime getApproveTime() {
		return approveTime;
	}

	public void setApproveTime(final LocalDateTime approveTime) {
		this.approveTime = approveTime;
	}

	public String getExt1() {
		return ext1;
	}

	public void setExt1(final String ext1) {
		this.ext1 = ext1;
	}

	public String getExt2() {
		return ext2;
	}

	public void setExt2(final String ext2) {
		this.ext2 = ext2;
	}

	public String getExt3() {
		return ext3;
	}

	public void setExt3(final String ext3) {
		this.ext3 = ext3;
	}

	public String getExt4() {
		return ext4;
	}

	public void setExt4(final String ext4) {
		this.ext4 = ext4;
	}

	public String getExt5() {
		return ext5;
	}

	public void setExt5(final String ext5) {
		this.ext5 = ext5;
	}

	public String getOrganCode() {
		return organCode;
	}

	public void setOrganCode(final String organCode) {
		this.organCode = organCode;
	}

	public void setContentTimeStr(final String contentTimeStr) {
		this.contentTimeStr = contentTimeStr;
	}

}